#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long 
signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> a;
    for(int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    vector<int> b(n - 1);
    for(int i = 1; i < n; i++) {
        b[i - 1] = a[i] - a[i - 1];
    }
    sort(b.begin(), b.end());
    int ret = 0;
    for(int i = 0; i < n - m; i++) {
        ret += b[i];
    }
    cout << ret + m << endl;
    return 0;
}